import store from "./store.js"
export default  = {
	// 判断是否正确
	showToast(title, url) {
		this.$refs.uToast.show({
			title,
			type: 'error',
			url,
			icon:false,
		})
	},
	// 计算剩余时间
	timeRemaining(val,time) {
		return new Promise((resolve, reject) => {
			let newTime = new Date().getTime();
			let oldTime = store.getItem(val);
			if (oldTime) {
				if (newTime > oldTime + time*1000) {
					resolve(0);
				} else {
					let downtime = Math.ceil(time + (oldTime - newTime) / 1000);
					resolve(downtime);
				}
			} else {
				store.setItem(val, newTime);
				resolve(time)
			}
		})
	}
}
